/**
 * Created by huangxuehua on 2017/12/6.
 */
//$(".goBack").click(function(){
//    window.history.go(-1)
//});

var xpHome = new Vue({
    el:'#app',
    data:{
        imgBaseUrl: nUrls.imgBaseUrl,//图片路径
        orderGoodsInfo:{},
        showGoodsList:[],//推荐信息列表
    },
    methods: {
        getImage:function(url){//加载图片  处理 url为空 加载出错
            if(url){
                return xpHome.imgBaseUrl+url;
            }
        },
        initData:function(){
            var orderInfo= window.localStorage.getItem("IndentGoodsInfo");
            if(orderInfo){
                xpHome.orderGoodsInfo=JSON.parse(orderInfo)
            }
        },
        //goComment:function(order_id){
        //    var orderInfo= window.localStorage.setItem("commentGoodsInfo",JSON.stringify(xpHome.orderGoodsInfo));
        //    window.location.href="../../order_detail/commentDistrict.html?id="+order_id
        //},
        //goOrderDetail:function(order_id){
        //    var orderInfo= window.localStorage.setItem("IndentGoodsDetail",JSON.stringify(xpHome.orderGoodsInfo));
        //    //console.log("--xpHome.orderGoodsInfo--",xpHome.orderGoodsInfo)
        //    window.location.href="../../order_detail/order_detail.html?id="+order_id
        //},
        goIndex:function(){  //到首页
            window.location.href = "../../../index.html";
        },
        goOrderInfo:function(pageType){ //到订单详情页
            window.location.href = "./indent.html?flag="+pageType;
        },
        getGoodsInfo:function(){ //获得商品详情
            $.ajax({
                url: nUrls.getThreeGoodsInfo,
                type:'post',
                success:function(data){
                    var result = eval('('+data+')');
                    if(result && result.code == 200){
                        //console.log(result)
                        xpHome.showGoodsList = result.data;
                        //console.log(xpHome.showGoodsList);
                    }
                },
                error:function(){
                    console.log("没有更多信息")
                }
            });
        },
        goDetail:function(good_id){
            window.location.href="../../detail/goods_detail.html?id="+good_id
        },
        goOnLine:function(){  //断网刷新
            nUtils.onLine();
        }

    }
});
$(function(){
    xpHome.initData()
    xpHome.getGoodsInfo()
})